package com.wanmait.demo.pojo;

import java.io.Serializable;
import java.util.Date;

public class Address implements Serializable {


    //zjj 我用来封装
    private District district;
    //zjj 我用来封装
    private Community community;


    private Town town;

    //zjj 我用来封装 封装userinfoid，需要对象
    private Userinfo userinfo=new Userinfo();

private Integer dizhi;

    public Integer getDizhi() {
        return dizhi;
    }

    public void setDizhi(Integer dizhi) {
        this.dizhi = dizhi;
    }

    private Integer id;

    /**
	* 区id
	*/
    private Integer destrictId;


    /**
	* 小区id
	*/
    private Community communityId;


    /**
	* 用户id
	*/
    private Integer userinfoId;

    /**
	* 联系人
	*/
    private String contactPerson;



    /**
	* l联系电话
	*/
    private String phoneNum;

    /**
	* 详细地址
	*/
    private String particulas;

    /**
	* 输入时间
	*/
    private Date inputTime;

    /**
	* 排序
	*/
    private Integer sort;

    /**
	* 是否启用
	*/
    private Boolean enable;
    private String completeAddress;
    /**
	* 是否默认地址
	*/
    private Boolean defaultAdress;

    private static final long serialVersionUID = 1L;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getDestrictId() {
        return destrictId;
    }

    public void setDestrictId(Integer destrictId) {
        this.destrictId = destrictId;
    }

    public Community getCommunityId() {
        return communityId;
    }

    public void setCommunityId(Community communityId) {
        this.communityId = communityId;
    }

    public Integer getUserinfoId() {
        return userinfoId;
    }

    public void setUserinfoId(Integer userinfoId) {
        this.userinfoId = userinfoId;
    }

    public String getContactPerson() {
        return contactPerson;
    }

    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public String getParticulas() {
        return particulas;
    }

    public void setParticulas(String particulas) {
        this.particulas = particulas;
    }

    public Date getInputTime() {
        return inputTime;
    }

    public void setInputTime(Date inputTime) {
        this.inputTime = inputTime;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Boolean getDefaultAdress() {
        return defaultAdress;
    }

    public void setDefaultAdress(Boolean defaultAdress) {
        this.defaultAdress = defaultAdress;
    }

    public District getDistrict() {
        return district;
    }

    public void setDistrict(District district) {
        this.district = district;
    }

    public Community getCommunity() {
        return community;
    }

    public void setCommunity(Community community) {
        this.community = community;
    }

    public Town getTown() {
        return town;
    }

    public void setTown(Town town) {
        this.town = town;
    }

    public Userinfo getUserinfo() {
        return userinfo;
    }

    public void setUserinfo(Userinfo userinfo) {
        this.userinfo = userinfo;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", dizhi=").append(dizhi);
        sb.append(", destrictId=").append(destrictId);
        sb.append(", communityId=").append(communityId);
        sb.append(", userinfoId=").append(userinfoId);
        sb.append(", contactPerson=").append(contactPerson);
        sb.append(", phoneNum=").append(phoneNum);
        sb.append(", particulas=").append(particulas);
        sb.append(", inputTime=").append(inputTime);
        sb.append(", sort=").append(sort);
        sb.append(", enable=").append(enable);
        sb.append(", defaultAdress=").append(defaultAdress);
        sb.append("]");
        return sb.toString();
    }
//    public String getCompleteAddress() {
//        Community community = this.getCommunity();
//        Town town=null;
//        District district=null;
//        String name1=this.particulas==null?"空":this.particulas;
//        String name2="";
//        String name3="";
//        String name4="";
//        if (communityId==null){
//            return name1;
//        }
//        name2=community.getCommunityName()==null?"空":community.getCommunityName();
//        town=community.getTown();
//        if (town==null){
//            return name2+name1;
//        }
//        name3=town.getTownName()==null?"空":town.getTownName();
//        district=town.getDistrict();
//        if (district==null){
//            return name3+name2+name1;
//        }
//        name4=district.getDistrictName()==null?"空":district.getDistrictName();
//        return name4+name3+name2+name1;
//    }
    public String getCompleteAddress()
    {
        String district=communityId.getTownId().getDistrictId().getDistrictName();
        String townName=communityId.getTownId().getTownName();
        String communityName=communityId.getCommunityName();

        return district+townName+communityName+particulas;
    }
}